package ci;

import java.io.IOException;
import java.util.HashMap;
import java.util.SortedMap;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ci.model.RecomendationsCI;

/**
 * Servlet implementation class TopMatches
 */
public class TopMatches extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public TopMatches() {
        super();
        // TODO Auto-generated constructor stub
    }

    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	RecomendationsCI sm = new RecomendationsCI();
    	HashMap<String,HashMap> persons = sm.info();
    	
    	String person1 = (String) request.getParameter("cmbTopMatches");
    	SortedMap<Double, String> TopMatchesPer = RecomendationsCI.topMatches(persons, person1, 6);
    	
    	request.setAttribute("TopMatchesPer", TopMatchesPer);
    	
    	request.setAttribute("nomTopMatches", person1);

		RequestDispatcher requestDispatcher = getServletContext().getRequestDispatcher("/similitud3.jsp");
		requestDispatcher.forward(request, response);

    }

}
